<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="/struts-tags" prefix="s" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>文章的添加</title>
		<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-2.0.0.min.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-ui.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath }/js/bootstrap.min.js"></script>
		
</head>

<body>
		<!-- 配置文件 -->
		<script type="text/javascript" src="${pageContext.request.contextPath }/utf8-jsp/ueditor.config.js" charset="utf-8"></script>
		<!-- 编辑器源码文件 -->
		<script type="text/javascript" src="${pageContext.request.contextPath }/utf8-jsp/ueditor.all.min.js" charset="utf-8"></script>
		
		<script type="text/javascript">
			function submitData()
			{
				var title = $("#title").val();
				var content = UE.getEditor('editor').getContent();
				var summary = $("#summary").val();
				if(title==null || title=="")
				{
					alert('请输入标题');
				}else if(content==null || content =="")
				{
					alert("请输入内容");
				}
				else if(summary==null || summary =="")
				{
					alert("请输入文章简介");
				}
				else{
					$.post("${pageContext.request.contextPath}/admin/essay_EssayAdd.action",{
											"essay.ename" : title,
											"essay.content" :content,
											"essay.summary" : summary
					
					 },function(result){
						if(result)
						{
							alert("文章发表成功");
							resetValue();
						}
						else
						{
							alert("文章发表失败");
						}
					},"text");
				
				}
			
			}
			function resetValue()
			{
				$("#title").val("");
				UE.getEditor('editor').setContent("");
				$("#summary").val("");
			}
		</script>
	<div id="p" class="easyui-panel" title="编写文章" style="padding: 10px">
	 	<table cellspacing="20px">
	   		<tr>
	   			<td width="80px">文章标题：</td>
	   			<td><input type="text" id="title" name="title" style="width: 400px;"/></td>
	   		</tr>
	   		<tr>
	   			<td>文章简介:</td>
	   			<td><input type="text" id="summary" name="summary" style="width: 400px; height: 80px"/></td>
	   		</tr>
	   		<tr>
	   			<td>文章内容：</td>
	   			<td>
					   <script id="editor" type="text/plain" style="width:100%;height:500px;"></script>
	   			</td>
	   		</tr>
	   		<tr>
	   			<td></td>
	   			<td>
	   				<a href="javascript:submitData()" class="easyui-linkbutton" data-options="iconCls:'icon-submit'">发表文章</a>
	   			</td>
	   		</tr>
	   	</table>
	 </div>
	 <script type="text/javascript">
		var ue = UE.getEditor('editor');
	</script>
</body>
</html>
